<template>
  <div id="app">
    <router-view class="view"></router-view>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {};
  },
  mounted: function () {
    this.getPartnerInfo();
    this.indexForward();
  },
  methods: {
    //实时获取用户信息
    getPartnerInfo() {
      var _self = this;
      var body = {};
      body.params = {};
      var url = this.utilHelper.apiUrl + "/api/getUserById";
      _self.$http.post(url, body).then((response) => {
        var data = response.body.resData;
        var result = data.result;
        if (result == "1") {
          window.localStorage.setItem("3_userId", data.id);
          window.localStorage.setItem("3_userName", data.accountName);
          window.localStorage.setItem("3_phone", data.phone);
          window.localStorage.setItem("3_isLogin", true);
          window.localStorage.setItem("3_userRole", data.userRoleId);
          window.localStorage.setItem("3_accountType", data.accountType);
        }
      });
    },
    indexForward() {
      var _self = this;
      var body = {};
      body.params = {};
      var url = this.utilHelper.apiUrl + "/api/getAgencyIndexSwitch";
      _self.$http.post(url, body).then((response) => {
        var data = response.body.resData;
        var result = data.agencyIndexSwitch;
        var agencyIndexSwitch = "1";
        if (result) {
          agencyIndexSwitch = result;
        }
        let isLogin = window.localStorage["3_isLogin"];
        if (isLogin == true || isLogin == "true") {
          return;
        }
        var _path = window.location.href;
        if (_path.indexOf("/sharePremisesDetail") != -1) {
          return;
        }
        console.info(
          window.location.href + "++++" + agencyIndexSwitch + "++++" + isLogin
        );

        if ("0" == agencyIndexSwitch) {
          layer.closeAll();
          this.$router.replace({
            path: "/login",
          });
        } else if ("1" == agencyIndexSwitch) {
          console.info("45454545");
          layer.closeAll();
          this.$router.replace({
            path: "/index",
          });
        }
      });
    },
    //授权页
  },
};
</script>
